package com.wyc.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Slf4j
public class MyAspect {


//    @Pointcut("execution(* com..DeptsService.*(..))")
    @Pointcut("@annotation(com.wyc.aop.MyLog)")
    private void xx(){};

    @Around("xx()")
    public Object recordTime(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println(1111);
        long begin=System.currentTimeMillis();
        Object proceed = proceedingJoinPoint.proceed();
        long end=System.currentTimeMillis();
        log.info(proceedingJoinPoint.getSignature()+"方法耗时："+(end-begin)+"毫秒");
        return proceed;

    }
}
